<template>
    <div>
        <el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
            <el-form-item label="用户名" prop="name">
                <el-input type="string"  v-model.number="ruleForm.name" ></el-input>
            </el-form-item>
            <el-form-item label="密码" prop="pass">
                <el-input type="password" v-model="ruleForm.pass" autocomplete="off"></el-input>
            </el-form-item>
            
            <el-form-item>
                <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
                <el-button @click="resetForm('ruleForm')">重置</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
    export default {
    data() {

      var validatePass = (_rule, value, callback) => {
        if (value === '') {
          callback(new Error('请输入密码'));
        } 
      };
      return {
        ruleForm: {
          pass: '',
          name:'',
        },
        rules: {
          name:[
              {min: 5, max:10, message:'名字为字符串', trigger: 'blur'}
          ],
          pass: [
            { min: 5, max:10 , message:'密码在5-10个字符',trigger:'blur'},
            { validator: validatePass, trigger: 'blur' }
          ],

        }
      };
    },
    methods: {
      submitForm(formName) {
        
        
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      }
    }
  }
</script>

<style lang="scss" scoped>

</style>